/*
 * DumperDecorator.java	2008/11/16
 *
 * Copyright 2008 Web & Zen Multimedia, All rights reserved.
 * Use is subject to license terms.
 */
package it.wzm.lightweightlog;

import it.wzm.lightweightlog.Constant.Severity;


/**
 * @author Leonardo Celati
 *
 */
public abstract class DumperDecorator extends Dumper {

	/**
	 * As required by serialization
	 */
	private static final long serialVersionUID = 7822652635014149651L;
	/**
	 * Holder for Dumper
	 */
	private Dumper d;
	
	/**
	 * Constructor
	 * @param d valid Dumper
	 */	
	protected DumperDecorator(Dumper d) {
		super(d);
		// cannot accept null value for Dumper
		if (d==null)
			throw new DumperInitializationException("Dumper is null for annotation");
		// otherwise...
		this.d=d;
	}

	/**
	 * Getter for Dumper
	 * @return the d
	 */
	protected Dumper getDumper() {
		return this.d;
	}

	   
	/**
	 * Implementing overridden method
	 */
	@Override
	public boolean isOpen() {
		return this.d.isOpen();
	}
	
	/**
	 * Implement overridden method
	 */
	@Override
	public void open() throws DumperException {
		this.d.open();
	}
	
    /**
     * Dump Entry, the method from 'Dumper:d' is used
     * @param e Anything extending Entry
     */
    @Override
    public <E extends Entry> void dump(E e) throws DumperException {
        this.d.dump(e);
    }
	
	@Override
	public void close() throws DumperException {
		this.d.close();
	}
	
}
